<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:h="http://xmlns.jcp.org/jsf/html"
   xmlns:p="http://primefaces.org/ui"
   template="/WEB-INF/templates/default.xhtml">
   
   	<f:metadata>
	   	<f:viewParam name="approvedMatterId" value="#{approvedMatterHome.id}"></f:viewParam>
	   	<f:event listener="#{approvedMatterHome.initConversation()}" type="preRenderView"></f:event>
	   	<f:viewParam name="moduleName" value="考核分类管理"></f:viewParam>
	   	<f:viewParam name="approvedClassId" value="#{approvedClassHome.id}"></f:viewParam>
   	</f:metadata>
   
   	<ui:define name="content">
   
		<h:form id="editForm">         
			<p:panel id="panel" header="#{approvedMatterHome.managed ? '修改' : '新增'}考核事项" style="margin-bottom:10px;">
		        <p:messages id="messages" closable="true"><p:autoUpdate/></p:messages>
		        
		        <h:panelGrid columns="2" cellpadding="5">
					<p:outputLabel for="matterName" value="考核内容" />				
					<p:inputTextarea id="matterName" 
							  	  value="#{approvedMatterHome.instance.matterName}"						  	   
						   	   required="true"
						   	   	   cols="80"
						   	   	   rows="5" />
						   
				    <p:outputLabel for="approvedClass" value="考核类别" />				
					<p:selectOneMenu id="approvedClass" 
							  value="#{approvedClassHome.instance}"
						   required="true">
						<f:selectItem itemLabel="请选择" itemValue="#{null}"/>
						<f:selectItems value="#{approvedClassList.resultList}" var="_class" itemLabel="#{_class.name}" itemValue="#{_class}"></f:selectItems>
						<f:converter converterId="entityConverter"></f:converter>
						<p:ajax update="@form:matterType"></p:ajax>
					</p:selectOneMenu>
					
					<p:outputLabel for="matterType" value="奖励/处罚" />
					<p:selectOneMenu id="matterType" 
							  value="#{approvedMatterHome.instance.matterType}"
						   required="true">
						<f:selectItem itemLabel="请选择" itemValue="#{null}"/>
						<f:selectItems value="#{enumUtils.getEnumArray('approved.MatterType')}" var="_type" itemLabel="#{_type.typeName}" itemValue="#{_type}"></f:selectItems>
					</p:selectOneMenu>	
									
										
					<p:outputLabel value="材料清单"></p:outputLabel>
					<p:panel styleClass="evidenceDefinationsPanel" id="evidenceDefinationsPanel" widgetVar="evidenceDefinationsPanel">
						<p:panelGrid cellpadding="5">
							<p:repeat var="_def" value="#{approvedMatterHome.instance.evidenceDefinations}" varStatus="_status">								
								<p:row>
									<p:column>
										<p:outputLabel for="matterName" value="材料名称"></p:outputLabel>
									</p:column>
									<p:column>
										<p:inputText id="matterName" value="#{_def.name}" required="true">
											<p:ajax event="blur" update="@form:evidenceDefinationsPanel" />
										</p:inputText>								
									</p:column>
									
									<p:column>
										<p:outputLabel value="是否必填"></p:outputLabel>
									</p:column>
									<p:column>
										<p:selectBooleanCheckbox id="required" value="#{_def.required}" >
											<p:ajax event="change" update="@form:evidenceDefinationsPanel" />
										</p:selectBooleanCheckbox>
									</p:column>
									
									<p:column>
										<p:commandButton action="#{approvedMatterHome.instance.removeEvidenceDefination(_status.index)}"
													  immediate="true"
													  	 update="@form:evidenceDefinationsPanel"
													  	  value="删除"></p:commandButton>
									</p:column>										
								</p:row>
							</p:repeat>
						</p:panelGrid>
						
						<p:commandButton action="#{approvedMatterHome.instance.addEmptyEvidenceDefination()}" 
									 update="@form"
								  immediate="true"
								  	  value="新增"></p:commandButton>
						
					</p:panel>	
				</h:panelGrid>
			</p:panel>
			
			<p:commandButton action="#{approvedMatterHome.saveAndFlush()}" value="保存" ajax="false" />
			<p:commandButton value="删除" action="#{approvedMatterHome.delete()}">
				<p:confirm header="请确认" message="您确认删除记录吗?" icon="ui-icon-alert" />
			</p:commandButton>
			<p:commandButton action="#{approvedMatterHome.cancel()}" value="取消" immediate="true"></p:commandButton>	
						
			<p:confirmDialog id="confirmDialog" global="true" showEffect="fade" hideEffect="explode" widgetVar="confirmDialog">
			    <p:commandButton value="确认" styleClass="ui-confirmdialog-yes"></p:commandButton>
			    <p:commandButton value="取消" immediate="true" styleClass="ui-confirmdialog-no" />
			</p:confirmDialog>
		</h:form>
        
   	</ui:define>
</ui:composition>
